<div class="header_menu">
    <div class="container">
        <div class="header-nav clearfix">
            <?php echo $this->partial('site/headermenu'); ?>
        </div>
    </div>
</div>
</div>

<div class="container">
    <div class="xm-plain-box">
        <div class="box-hd">
            <h3 class="title"><?php echo $this->translate('会员登录'); ?></h3>
        </div>
        <div class="box-bd">
            <div class="row">
                <form class="form-horizontal" method="post" name="login_form" id="login_form">
                    <div class="control-group">
                        <div class="message_one">
                        </div>
                    </div>
                    <?php
                    $userPlaceholder = $this->translate('会员名称');
                    if($this->email_login_state == 'true') $userPlaceholder .= '/'.$this->translate('电子邮箱');
                    if($this->phone_login_state == 'true') $userPlaceholder .= '/'.$this->translate('手机号码');
                    ?>
                    <div class="control-group">
                        <label for="input01" class="control-label"><?php echo $this->translate('会员名称'); ?><span class="must_add_value">*</span>：</label>
                        <div class="controls">
                            <input type="text" id="user_name" placeholder="<?php echo $userPlaceholder; ?>" name="user_name">
                        </div>
                    </div>
                    <div class="control-group">
                        <label for="input01" class="control-label"><?php echo $this->translate('会员密码'); ?><span class="must_add_value">*</span>：</label>
                        <div class="controls">
                            <input type="password" id="user_password" name="user_password" placeholder="<?php echo $this->translate('输入会员密码'); ?>">
                        </div>
                    </div>
                    <?php if ($this->frontwebsite()->websiteCaptchaState('user_login_captcha') == 'true') { ?>
                        <div class="control-group">
                            <label for="input01" class="control-label"><?php echo $this->translate('验证码'); ?><span class="must_add_value">*</span>：</label>
                            <div class="controls">
                                <input type="text" class="input-small" id="captcha_code" name="captcha_code" placeholder="<?php echo $this->translate('输入验证码'); ?>">&nbsp;<span id="login_captcha_id"></span>
                            </div>
                        </div>
                    <?php } ?>
                    <div class="control-group">
                        <div class="controls">
                            <input type="hidden" name="<?php echo $this->login_csrf['name']; ?>" value="<?php echo $this->login_csrf['value']; ?>" />
                            <input type="hidden" name="http_referer" value="<?php echo $this->http_referer; ?>" />
                            <button class="btn btn-primary" type="submit"><?php echo $this->translate('会员登录'); ?></button>
                            &nbsp;&nbsp;
                            &nbsp;&nbsp;<button class="btn" type="button" onclick="location.href='<?php echo $this->url('frontuser/default',array('action'=>'register')); ?>'"><?php echo $this->translate('还不是会员，去注册会员'); ?></button>
                            <p style="margin-top:10px;"><a href="<?php echo $this->url('frontuser/default',array('action'=>'forgotpasswd')); ?>"><?php echo $this->translate('会员忘记密码'); ?></a></p>
                        </div>
                    </div>
                    <?php if($this->frontwebsite()->getUserOtherLoginState() == 'true') { ?>
                        <div class="control-group">
                            <label for="input01" class="control-label"><?php echo $this->translate('其他登录'); ?>：</label>
                            <div class="controls">
                                <?php
                                $otherLoginArray = $this->frontwebsite()->getUserOtherLoginIni();
                                if(!empty($otherLoginArray)) {
                                    foreach($otherLoginArray as $othKey => $othValue) {
                                        if($othValue['login_state'] == 'true') {
                                            $othKey = strtolower($othKey);
                                            ?>
                                            <a href="<?php echo $this->url('frontuser/default',array('action'=>'otherlogin'), array('query'=>array('login_type'=>$othKey))); ?>" style="margin-right: 8px;"><img src="<?php echo $this->basePath('public/img/login/'.$othKey.'_login.png'); ?>"></a>
                                            <?php
                                        }
                                    }
                                }
                                ?>
                            </div>
                        </div>
                    <?php } ?>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
    <?php if (isset($this->message) and $this->message != '') { ?>
    show_message('.message_one','<?php echo date("Y-m-d H:i:s",time()); ?>','<?php echo $this->message; ?>','alert-error');
    <?php } ?>
    //客户登录验证
    $(document).ready(function() {
        $("#login_form").validate({
            success : function(label){
                label.addClass('validate_right').text('OK!');
            },
            rules: {
                user_name: {
                    required: true
                },
                user_password: {
                    required: true
                }
                <?php if ($this->frontwebsite()->websiteCaptchaState('user_login_captcha') == 'true') { ?>
                ,
                captcha_code: {
                    required:true,
                    remote :{
                        url : '<?php echo $this->url('shopfront/default/captcha-check',array('action'=>'captcha','captcha_check'=>1)); ?>',
                        type : 'post',
                        date : {
                            captcha_code :function(){
                                return $("#captcha_code").val();
                            }
                        }
                    }
                }
                <?php } ?>
            },
            messages: {
                user_name: {
                    required: "<?php echo $this->translate('请输入会员登录名称！'); ?>"
                },
                user_password: {
                    required: "<?php echo $this->translate('请输入密码！'); ?>"
                }
                <?php if ($this->frontwebsite()->websiteCaptchaState('user_login_captcha') == 'true') { ?>
                ,
                captcha_code: {
                    required:"<?php echo $this->translate('验证码不能为空！'); ?>",
                    remote : "<?php echo $this->translate('验证码错误！'); ?>"
                }
                <?php } ?>
            }
        });
    });

    <?php if ($this->frontwebsite()->websiteCaptchaState('user_login_captcha') == 'true') { ?>
    //验证码添加
    function captchaAdd() {
        $.get("<?php echo $this->url('shopfront/default',array('action'=>'captcha')); ?>",{},
            function(data){
                $("#login_captcha_id").html('<img src="<?php echo $this->basePath('/'); ?>'+data.captcha_file+'" border="0" >&nbsp;&nbsp;<a href="javascript:;" onclick="captchaAdd()"><?php echo $this->translate('更换验证码'); ?></a>');
            },'json');
    }
    captchaAdd();
    <?php } ?>
</script>
